package com.swh;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.swh.context.App;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/10 16:47
 * @Version: 1.0
 */
public class start implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(App.class);

        DispatcherServlet servlet = new DispatcherServlet(context);
        ServletRegistration.Dynamic registration = servletContext.addServlet("abc", servlet);
        registration.setLoadOnStartup(1);
        registration.addMapping("/");

    }
}
